﻿using H.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace H.Hands.Remotings
{
    public class HandRef : MarshalByRefObject, IHand
    {
        private readonly IHand _Hand;

        public HandRef(string handName)
        {
            _Hand = IPlugin.GetObject<IHandFactory>(handName).CreateInstance() ?? throw new Exception("无法加载插件");
        }

        ///<inheritdoc/>
        public bool AllKeyUp()
        {
            return _Hand.AllKeyUp();
        }

        ///<inheritdoc/>
        public bool AllMouseUp()
        {
            return _Hand.AllMouseUp();
        }

        ///<inheritdoc/>
        public IKeyBoard CreateKey(HandKey key)
        {
            return new KeyBoardRef(_Hand.CreateKey(key));
        }

        public IKeyBoard CreateKeys(params HandKey[] keys)
        {
            return new KeyBoardRef(_Hand.CreateKeys(keys));
        }


        public IMouse LeftMouse()
        {
            return new MouseRef(_Hand.LeftMouse());
        }

        public IMouse MiddleMouse()
        {
            return new MouseRef(_Hand.MiddleMouse());
        }


        public IMouse RightMouse()
        {
            return new MouseRef(_Hand.RightMouse());
        }

        ///<inheritdoc/>
        public void Dispose()
        {
            _Hand.Dispose();
        }

        ///<inheritdoc/>
        public bool GetCapsLock(out bool lightOn)
        {
            return _Hand.GetCapsLock(out lightOn);
        }

        ///<inheritdoc/>
        public bool GetNumLock(out bool lightOn)
        {
            return _Hand.GetNumLock(out lightOn);
        }

        ///<inheritdoc/>
        public bool InputString(string words)
        {
            return _Hand.InputString(words);
        }



        ///<inheritdoc/>
        public bool MousePoint(ref Pos point)
        {
            return _Hand.MousePoint(ref point);
        }

        ///<inheritdoc/>
        public bool MoveTo(Pos point)
        {
            return _Hand.MoveTo(point);
        }

        ///<inheritdoc/>
        public bool MoveToRelative(Pos offset)
        {
            return _Hand.MoveToRelative(offset);
        }


        ///<inheritdoc/>
        public bool Scroll(int count)
        {
            return _Hand.Scroll(count);
        }

        ///<inheritdoc/>
        public bool WheelDown(int count)
        {
            return _Hand.WheelDown(count);
        }

        ///<inheritdoc/>
        public bool WheelUp(int count)
        {
            return _Hand.WheelUp(count);
        }
    }
}
